//
//  HLRtcOptionRequest.m
//  YueYue
//
//  Created by hulu001 on 2023/6/21.
//

#import "HLRtcOptionRequest.h"

@implementation HLRtcOptionRequest
{
    NSDictionary *_params;
    HLRtcOptionType _type;
}

- (id)initWithType:(HLRtcOptionType)type params:(NSDictionary *)params
{
    self = [super init];
    
    if (self) {
        _type = type;
        _params = params;
    }
    
    return self;
}



- (NSString *)requestUrl
{
    switch (_type) {
        case HLRtcOptionTypeVideoCall:
            return @"/call/platform/female/v2";
            break;
        case HLRtcOptionTypeMaleJoin:
            return @"/male/join/temp";
            break;
        case HLRtcOptionTypeMaleChat:
            return @"/male/join/chat";
            break;
    }
    
}

- (YTKRequestMethod)requestMethod
{
    switch (_type) {
        case HLRtcOptionTypeVideoCall:
            return YTKRequestMethodPOST;
            break;
        case HLRtcOptionTypeMaleJoin:
            return YTKRequestMethodGET;
            break;
        case HLRtcOptionTypeMaleChat:
            return YTKRequestMethodGET;
            break;
    }
    return YTKRequestMethodGET;
}

- (id)requestArgument
{
    if (_params){
        return _params;
    } else {
        return @{};
    }
}

- (HLRtcTokenModel *)token
{
    HLRtcTokenModel *token;
    
    NSDictionary *data = [self.result valueForKey:@"data"];
    if (![data isKindOfClass:[NSDictionary class]]){
        return token;
    }
    token = [HLRtcTokenModel mj_objectWithKeyValues:data];
    
    return token;
}

@end
